<?php include('includes/start_session.php') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>e-class searched courses</title>
	
	<link rel="stylesheet" href="styles/site.css" type="text/css" />
	<link rel="stylesheet" href="styles/less_padding.css" type="text/css" />
    
    <script src="scripts/scripts.js" type="text/javascript"></script>	
</head>
<body onload="same_height()">
	<?php include('includes/header.php') ?>
	<div id="content" class="content_padding">
		<div id="courses">
			<?php
            	if(isset($_GET['message']) && $_GET['message'] == '1')
            		echo '<div class="center_align"><span class="success">Η αλλαγή έγινε με επιτυχία</span></div>';
            ?>
			<h4>Αποτελέσματα Αναζήτησης</h4>
			<?php
				include('db-api/txt-db-api.php');
				include('includes/course_info.php');				
				
				function ShowResults()
				{
					if(!isset($_SESSION['search']))
					{
						echo 'Δε βρέθηκαν μαθήματα που να ικανοποιούν τα κριτήρια που δώσατε';
						return;
					}
					$db = new Database('Eclass');
					$rs = $db->executeQuery($_SESSION['search']);
					if(!$rs->next())
					{
						echo 'Δε βρέθηκαν μαθήματα που να ικανοποιούν τα κριτήρια που δώσατε';
						return;
					}
					echo '<ul class="course_list">';
					$flag = true;
					do
					{
						list($id, $name, $description, $subcat) = $rs->getCurrentValues();
						if($flag == true)
						{
							echo '<li class="first_course">';
							$flag = false;
						}
						else
							echo '<li>';

						echo '<div class="course">';
						
						echo '<a href="course.php?id=' . $id . '" class="title">' . $name . '</a>';
						ShowProfessors($id);
						if(ShowProfessorAnchor($id) == true)
						{
							ShowWatchAnchor($id);
						}
						
						echo '</div>';
						echo '</li>';
					} while($rs->next());
					echo '</ul>';
					echo '<div class="right_align"><a href="#" class="course_anchor">
						Επιστροφή στην κορυφή</a></div>';
				}
			
				$_SESSION['previous_page'] = 'searched_courses.php';
				ShowResults();
			?>
		</div>
	</div>
	<?php include('includes/footer.php'); ?>
</body>
</html>
